package com.siyu.rehearsal.previewriska.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.rehearsal.previewriska.domain.PreviewRiskA;
import com.siyu.rehearsal.previewriska.service.IPreviewRiskAService;

/**
 * 预演结果风险评估Controller
 *
 * @author hrhy
 * @date 2024-06-15
 */
@RestController
@RequestMapping("/rehearsal/previewriska")
public class PreviewRiskAController extends BaseController
{
    @Autowired
    private IPreviewRiskAService previewRiskAService;

    /**
     * 查询预演结果风险评估列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PreviewRiskA previewRiskA)
    {
        startPage();
        List<PreviewRiskA> list = previewRiskAService.selectPreviewRiskAList(previewRiskA);
        return getDataTable(list);
    }

    /**
     * 导出预演结果风险评估列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, PreviewRiskA previewRiskA)
    {
        List<PreviewRiskA> list = previewRiskAService.selectPreviewRiskAList(previewRiskA);
        ExcelUtil<PreviewRiskA> util = new ExcelUtil<PreviewRiskA>(PreviewRiskA.class);
        util.exportExcel(response, list, "预演结果风险评估数据");
    }

    /**
     * 获取预演结果风险评估详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(previewRiskAService.selectPreviewRiskAById(id));
    }

    /**
     * 新增预演结果风险评估
     */
    @PostMapping
    public AjaxResult add(@RequestBody PreviewRiskA previewRiskA)
    {
        return toAjax(previewRiskAService.insertPreviewRiskA(previewRiskA));
    }

    /**
     * 修改预演结果风险评估
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PreviewRiskA previewRiskA)
    {
        return toAjax(previewRiskAService.updatePreviewRiskA(previewRiskA));
    }

    /**
     * 删除预演结果风险评估
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(previewRiskAService.deletePreviewRiskAByIds(ids));
    }
}
